﻿using System;
using Oracle.ManagedDataAccess.Client;

namespace test
{
    public enum TestCase
    {

    }
    class Program
    {
        static void Main(string[] args)
        {
            var connStr = "User Id=system;Password=szoscar55;Data Source=10.1.203.66:1521/ora";
            //var connStr = "User Id=system;Password=szoscar55;Data Source=10.1.203.20:5003/ora";

            using (var connect = new OracleConnection(connStr))
            {
                connect.Open();
                using (var command = connect.CreateCommand())
                {
                    command.BindByName = true;

                    // command.CommandText = "SELECT * FROM TAB_TEST";

                    // command.CommandText = "SELECT * FROM TAB_TEST WHERE id = 1";

                    // command.CommandText = "SELECT * FROM TAB_TEST WHERE id > :v1";
                    // command.Parameters.Add(new OracleParameter("v1", OracleDbType.Int32) { Value = 0 });

                    // command.CommandText = "SELECT * FROM TAB_TEST WHERE id = :v1 AND name = :v2";
                    // command.Parameters.Add(new OracleParameter("v1", OracleDbType.Int32) { Value = 2 });
                    // command.Parameters.Add(new OracleParameter("v2", OracleDbType.Varchar2) { Value = "v2" });

                    command.CommandText = "SELECT * FROM TAB_TEST WHERE id = :v1 AND name = :v2";
                    command.Parameters.Add(new OracleParameter("v2", OracleDbType.Varchar2) { Value = "v2" });
                    command.Parameters.Add(new OracleParameter("v1", OracleDbType.Int32) { Value = 2 });

                    // command.CommandText = "SELECT * FROM TAB_TEST WHERE id = :v1 AND name = :v2 AND num = :v1";
                    // command.Parameters.Add(new OracleParameter("v1", OracleDbType.Int32) { Value = 2 });
                    // command.Parameters.Add(new OracleParameter("v2", OracleDbType.Varchar2) { Value = "v2" });

                    // command.CommandText = "SELECT * FROM TAB_TEST WHERE id = :v1 AND name = :v2 AND num = :v1";
                    // command.Parameters.Add(new OracleParameter("v2", OracleDbType.Varchar2) { Value = "v2" });
                    // command.Parameters.Add(new OracleParameter("v1", OracleDbType.Int32) { Value = 2 });

                    // command.CommandText = "SELECT * FROM TAB_TEST WHERE id = :v1 AND name = :v2 AND num = :v1";
                    // command.Parameters.Add(new OracleParameter("v1", OracleDbType.Int32) { Value = 6 });
                    // command.Parameters.Add(new OracleParameter("v2", OracleDbType.Varchar2) { Value = "v6" });

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Console.WriteLine("output: id-> {0} , name -> {1}", reader.GetString(0), reader.GetString(1));
                        }
                    }
                }


            }
            Console.WriteLine("Input any key to exit.");
        }
    }
}
